#!/usr/bin/env python 

import inkex
import simplestyle, sys
import andengineutils

class AndEngine(inkex.Effect):
    def __init__(self):
        """
        Constructor.
        Defines the "--what" option of a script.
        """
        # Call the base class constructor.
        inkex.Effect.__init__(self)
        
        # Define string option "--what" with "-w" shortcut and default value "World".
        self.OptionParser.add_option("--issensor", action="store", type="inkbool", dest="issensor", default=False, help="is sensor")
        self.OptionParser.add_option("--isawake", action="store", type="inkbool", dest="isawake", default=True, help="is awake")
        self.OptionParser.add_option("--issleepingallowed", action="store", type="inkbool", dest="issleepingallowed", default=True, help="is sleeping allowed")
        self.OptionParser.add_option("--isbullet", action="store", type="inkbool", dest="isbullet", default=False, help="is bullet")
        self.OptionParser.add_option("--isactive", action="store", type="inkbool", dest="isactive", default=True, help="is active")
        self.OptionParser.add_option("--fixedrotation", action="store", type="inkbool", dest="fixedrotation", default=False, help="fixed rotation")
        self.OptionParser.add_option("--updateposition", action="store", type="inkbool", dest="updateposition", default=True, help="update position")
        self.OptionParser.add_option("--updaterotation", action="store", type="inkbool", dest="updaterotation", default=True, help="update rotation")
        
        
    def effect(self):
        for id, node in self.selected.iteritems():
            
            andengineutils.creatOrDelete("andengine-issensor", node, self.options.issensor, False)
            andengineutils.creatOrDelete("andengine-isawake", node, self.options.isawake, True)
            andengineutils.creatOrDelete("andengine-issleepingallowed", node, self.options.issleepingallowed, True)
            andengineutils.creatOrDelete("andengine-isbullet", node, self.options.isbullet, False)
            andengineutils.creatOrDelete("andengine-isactive", node, self.options.isactive, True)
            andengineutils.creatOrDelete("andengine-fixedrotation", node, self.options.fixedrotation, False)
            andengineutils.creatOrDelete("andengine-updateposition", node, self.options.updateposition, True)
            andengineutils.creatOrDelete("andengine-updaterotation", node, self.options.updaterotation, True)
            
        
if __name__ == '__main__':
    e = AndEngine()
    e.affect()